const path = require('path');
const {LifeCircleService,ReadJsonFileList} = require("./service/ConfigService")
const {CoinOrderService} = require("./service/CoinOrderService")
const {TxLogService,SysLogService} = require("./service/LogService")
const {main} = require("./service/MainService")
const {EmailService} = require('./service/EmailService')

//生命周期日志
const lifeCircleService = new LifeCircleService(path.join(__dirname,"log","lifeCircleLog.log"));

//读取配置文件
const allConfig = ReadJsonFileList(path.join(__dirname,"config"),['account','runtime'])

//订单服务
const coinOrderService = new CoinOrderService(allConfig);

//交易日志服务
const txLogService = new TxLogService(path.join(__dirname,"log","tx"));

//系统运行日志
const sysLogService = new SysLogService(path.join(__dirname,"log"));

const allService = {lifeCircleService,coinOrderService,txLogService,sysLogService};

//添加邮件服务
if(allConfig.account.email){
	const {user,pass} = allConfig.account.email;
	allService.emailService = new EmailService(user,pass)
}

main(allConfig,allService)

